<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    //对象字面量
    var dog ={
        dogName: "可可",
        type: "阿拉斯加犬",
        age: "5岁",
        color: "棕红色",
        bark: function(){
            console.log("汪汪汪");
        },
        showFilm: function(){
            console.log("扮演军犬");
        }
    }
    console.log(dog.dogName);
    console.log(dog.age);
    dog.showFilm();
    console.log(dog.color); 

    //new Object创建对象
    var people =new Object();
    people.pName="Naruto";
    people.sex="男";
    people.age="19岁";
    people.skill=function(){
        console.log("影分身术");
    }
    console.log(people.pName);
    console.log(people.sex);
    console.log(people.age);
    people.skill();

    //构造函数创建对象
    function Hero(uname,type,blood){
        this.uname=uname;
        this.type=type;
        this.blood=blood;
        this.attack=function(ways){
            console.log(ways);
        }
    }
    var lp=new Hero("廉颇","力量型","500血量");
    console.log(lp.uname);
    console.log(lp.type);
    console.log(lp.blood);
    lp.attack("近战");
    var hy=new Hero("后裔","射手型","100血量");
    console.log(hy.uname);
    console.log(hy.type);
    console.log(hy.blood);
    hy.attack("远程");
</script>
<body>
    
</body>
</html>